package com.td.module.farmer.convert.plantinginformation;

import com.td.framework.common.pojo.PageResult;
import com.td.module.farmer.controller.admin.plantinginformation.vo.PlantingInformationCreateReqVO;
import com.td.module.farmer.controller.admin.plantinginformation.vo.PlantingInformationExcelVO;
import com.td.module.farmer.controller.admin.plantinginformation.vo.PlantingInformationRespVO;
import com.td.module.farmer.controller.admin.plantinginformation.vo.PlantingInformationUpdateReqVO;
import com.td.module.farmer.dal.dataobject.plantinginformation.PlantingInformationDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 种植信息 Convert
 *
 * @author 王翔翔
 */
@Mapper
public interface PlantingInformationConvert {

    PlantingInformationConvert INSTANCE = Mappers.getMapper(PlantingInformationConvert.class);

    @Mappings({
            @Mapping(target = "coordinates", expression = "java(com.td.framework.common.util.json.JsonUtils.toJsonString(bean.getCoordinates()))")
    })
    PlantingInformationDO convert(PlantingInformationCreateReqVO bean);
    @Mappings({
            @Mapping(target = "coordinates", expression = "java(com.td.framework.common.util.json.JsonUtils.toJsonString(bean.getCoordinates()))")
    })
    PlantingInformationDO convert(PlantingInformationUpdateReqVO bean);

    @Mappings({
            @Mapping(target = "coordinates", expression = "java(com.td.framework.common.util.json.JsonUtils.parseObject(bean.getCoordinates(), new com.fasterxml.jackson.core.type.TypeReference<List<List<Double>>>() {}))")
    })
    PlantingInformationRespVO convert(PlantingInformationDO bean);

    List<PlantingInformationRespVO> convertList(List<PlantingInformationDO> list);

    PageResult<PlantingInformationRespVO> convertPage(PageResult<PlantingInformationDO> page);

    List<PlantingInformationExcelVO> convertList02(List<PlantingInformationDO> list);

}
